<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        button {
            width: 60px;
            height: 30px;
        }

        body {
            background-color: skyblue;
        }

        .box1 {
            width: 500px;
            height: 100%;
            background-color: red;
            position: absolute;
            right: -500px;
            top: 0;
            /* overflow: hidden; */
        }

        .active {
            transform: translateX(-500px);
            transition: all ease 2s;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="add">点击</button>
        <div class="box1" v-bind:class="Obj"></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                Obj: {
                    active: false
                },
            },
            methods: {
                add: function () {
                    this.Obj.active = !this.Obj.active;
                }
            },
        })
    </script>
</body>

</html>